#ifndef RP2GEOMETRY_H
#define RP2GEOMETRY_H

#include "Rp2Spatial.h"
#include "Rp2VertexBuffer.h"
#include "Rp2IndexBuffer.h"
#include "Rp2LightingEffect.h"
#include "Rp2Matrix4.h"

namespace Rp2
{

class VertexBuffer;

class Geometry : public Spatial
{

RP2_DECLARE_RTTI;
RP2_DECLARE_NAME_ID;

public:
	virtual ~Geometry();

	// member access
	VertexBufferPtr VBuffer;
	IndexBufferPtr IBuffer;
	BoundingVolumePtr ModelBound;

protected:
	Geometry();
	Geometry(VertexBuffer* pkVBuffer, IndexBuffer* pkIBuffer);

	// geometry updates
	virtual void UpdateModelBound();
	virtual void UpdateWorldBound();
	virtual void UpdateModelNormals();

	virtual void UpdateMS (bool bUpdateNormals = true);

	virtual void UpdateState(std::vector<GlobalState*>* akGStack, std::vector<Light*>* pkLStack);

	virtual void GetVisibleSet(Culler& rkCuller, bool bNoCull);

	// ** not used now
//     // Dynamic lighting.  The effect is pushed onto the front of Spatial's
//     // effect array so that lighting occurs before other shader effects.
// 	LightingEffectPtr m_spkLEffect;

// internal use
public:
    // Compute the homogeneous world matrix from the components of the World
    // transformation.
	virtual void UpdateWorldData(double dAppTime);

    enum GeometryType
    {
        GT_POLYPOINT,
        GT_POLYLINE_SEGMENTS,
        GT_POLYLINE_OPEN,
        GT_POLYLINE_CLOSED,
        GT_TRIMESH,
        GT_TRISTRIP,
        GT_TRIFAN,
        GT_MAX_QUANTITY
    };

    GeometryType Type;

	GlobalStatePtr States[GlobalState::MAX_STATE_TYPE];

	Matrix4f HWorld; // homogeneous world matrix
};

#include "Rp2Geometry.inl"

}

#endif